Skip to content

fix: prefer unresolved sys.executable to stay inside venv#310

Merged
pancacake merged 1 commit intoHKUDS:devfrom
markjanzer:fix/resolve-python-venv-symlink
Apr 14, 2026
Merged

fix: prefer unresolved sys.executable to stay inside venv#310
pancacake merged 1 commit intoHKUDS:devfrom
markjanzer:fix/resolve-python-venv-symlink

Conversation

@markjanzer
Copy link
Copy Markdown
Contributor

@markjanzer markjanzer commented Apr 13, 2026

Summary

  • On macOS with Homebrew Python, _resolve_python() in start_tour.py resolves venv symlinks back to the system interpreter. PEP 668 then blocks pip install with an "externally-managed-environment" error, causing the setup tour to fail.
  • Swaps the check order so the unresolved venv path (sys.executable) is preferred when it exists, falling back to the resolved path only when necessary.

Test plan

  • Run python -m venv .venv && source .venv/bin/activate && python scripts/start_tour.py on macOS with Homebrew Python
  • Verify the bootstrap and pip installs use the venv Python, not the system Python
  • Confirm the tour completes without "externally-managed-environment" errors

🤖 Generated with Claude Code

On macOS with Homebrew Python, `Path(sys.executable).resolve()` follows
the venv symlink back to the system interpreter.  PEP 668 then blocks
pip installs with "externally-managed-environment", causing the setup
tour to fail.

Swap the check order so the unresolved venv path is preferred when it
exists, falling back to the resolved path only when necessary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pancacake
Copy link
Copy Markdown
Collaborator

Thanks for your contribution!

@pancacake pancacake merged commit 5342af3 into HKUDS:dev Apr 14, 2026
@markjanzer markjanzer deleted the fix/resolve-python-venv-symlink branch April 14, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants